package com.jianguozh.difs.support.service.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jianguozh.difs.support.service.sys.entity.Client;
import com.jianguozh.difs.support.service.sys.mapper.ClientMapper;
import com.jianguozh.difs.support.service.sys.service.IClientService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;

/**
 * <p>
 * 应用 服务实现类
 * </p>
 *
 * @author hanrs
 * @since 2022-03-17
 */
@Service
public class ClientServiceImpl extends ServiceImpl<ClientMapper, Client> implements IClientService {

    @Override
    @Transactional
    public boolean removeById(Serializable id) {
        getBaseMapper().deleteClientRoles(id);
        return super.removeById(id);
    }

    @Override
    public Client getByAppId(String appId) {
        return getBaseMapper().selectOne(new LambdaQueryWrapper<Client>().eq(Client::getAppId, appId));
    }
}
